<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width initial-sacle=1.0">
		    <meta http-equiv="x-ua-compatible" content="ie=edge">
		<link rel="stylesheet" href="http://localhost:3031/publish/css/index.css">
		<link rel="stylesheet" href="http://localhost:3031/publish/bootstrap4/dist/css/bootstrap.css">
		<link rel="stylesheet" href="http://localhost:3031/publish/font-awesome-4.7.0/css/font-awesome.css">
		<title></title>
		<script type="text/javascript" src="http://localhost:3031/publish/js/jquery-3.5.1.slim.min.js"></script>
		<script type="text/javascript" src="http://localhost:3031/publish/bootstrap4/dist/js/bootstrap.bundle.js"></script>
		<script type="text/javascript" src="http://localhost:3031/publish/bootstrap4/dist/js/bootstrap.js"></script>
		<script type="text/javascript" src="http://localhost:3031/publish/js/index.js"></script>

	</head>
	
	<body>
		<div class="container-fluid bg_div" >
			<ol class="d-flex flex-row">
				<li>
					<h5 class="text-white pr-5 g_line">欢迎进入新闻管理系统网站</h5>
				</li>
				<form action="" method="post" enctype="application/x-www-form-urlencoded">
				<li class="li_br px-3" >
					<span style="border-radius: 25px;"><img src="http://localhost:3031/publish/images/logins.png" alt="" width="40px" height="40px"></span>
					<span class="text-white" style="line-height: 55px">admin</span><i class="fa fa-caret-down text-white pl-2"></i>
				</li>
				</form>
				<li class="ml-auto text-white mr-5 px-3 li_br" >
					<span>网站首页</span>
				</li>
			</ol>
		</div>
		<div class="container-fluid text-white">
			<ul class="row">
				<li class="col-md-2 col-4 li_p">
				<div id="example" class="w-75">
					<ul class="card border-0 p-0 rounded-0 bg_div2">
						<li class="card-header p-0">
							<a class="btn btn-link w-100 text-left text-black-50 btn_txt py-3" data-toggle="collapse" data-target="#one">管理员设置
							<span class="out"></span>
							</a>
							<div class="card-body collapse show border-0 p-0" id="one" data-parent="#example">
								<div class="d-flex flex-column mr-auto">
									<a href="/admin" class=" btn_bg">管理员列表</a>
								<a href="#" class=" btn_bg">角色列表</a>
								</div>
								
							</div>
						</li>
						<li class="card-header p-0">
							<button class="btn btn-link w-100 text-left text-black-50 btn_txt py-3" data-toggle="collapse" data-target="#two" >新闻设置
							<span class="out"></span>
							</button>
							<div class="card-body collapse show border-0 p-0" id="two" data-parent="#example">
								<div class="d-flex flex-column mr-auto">
									<a href="#" class=" btn_bg">新闻类型</a>
								<a href="/" class=" btn_bg active">新闻列表</a>
								</div>
								
							</div>
						</li>
					</ul>
				</div>
				</li>
				<li class="col-md-10 col-8">
					<div>
						<ul class="d-flex flex-column">
							<li class=" text-black-50 border-bottom pt-3">
								<p>新闻管理 --- 新闻列表</p>
							</li>
							<li class="my-3">
								<ol class="d-flex flex-row">
									<li>
										<select name="cengar" class="form-control w-100" id="sar">
											<option value="">请选择新闻类型</option>
											<option value ="1" <% if(result[0].cengar == 1) { %> selected <%}%>>最新资讯</option>

									        <option value ="2" <% if(result[0].cengar == 2) { %> selected <%}%>>产品新闻</option>
									        <option value ="3" <% if(result[0].cengar == 3) { %> selected <%}%>>公司资讯</option>
								        </select>

								</li>
									<li>
										<input type="date" class="mx-3 w-100 form-control" placeholder="请选择搜索开始时间">
									</li>
									<li class="mx-4">
										<input type="date" class=" w-100 form-control" placeholder="请选择搜索结束时间">
									</li>
									<li>
										<button type="button" class="btn w-100 rounded-0 bg_btn" onclick="se()" >
											<i class="fa fa-search text-white"></i>
										</button>
									</li>
								</ol>
								
								
								
							</li>
							<li class="my-3">
								<a href="/add" class="btn w-10 rounded-0 text-white bg_btn">添加新闻</a>
							</li>
							<li>
								<form action="">
									<table class="table table-bordered text-black-50 table-hover" id="app">
										<tr class="bg-light">
											<th>ID</th>
											<th>文章标题</th>
											<th>文章类型</th>
											<th>点击数</th>
											<th>排序值</th>
											<th>置顶</th>
											<th>状态</th>
											<th>发布时间</th>
											<th>管理</th>
										</tr>
										<% result.forEach((item)=>{%>
											<tr>
												<td><%= item.id%></td>
												<td><%= item.title%></td>
												<td>
													<% if(item.cengar ==1){%>
														最新资讯
													<%}else if(item.cengar == 2){%>
														产品新闻
													<%}else{%>
														公司资讯
													<%}%>
												</td>


												<td>1</td>
												<td>1</td>
												<td>
													<% if(item.top==1){%>
														不置顶
													<%}else{%>
														置顶
													<%}%>
												</td>
												<td>
													<% if(item.status==1){%>
														不可见
													<%}else{%>
														可见
													<%}%></td>
												<td><%= moment(item.time).format('Y/M/D')%></td>
												<td>
													<a href="/edit/<%=item.id%>" class="btn btn-primary text-white">编辑</a>
													<a href="javascript:del(<%=item.id%>)" class="btn btn-danger text-white">删除</a>
												</td>
											</tr>
										<%})%>

									</table>
								</form>

							</li>
							<li style="margin: 0 auto;">
								<button class="btn border mx-2">
									<a href="#" id="btn_a">上一页</a>
								</button>
								<button class="btn border mx-2">
									<a href="#" id="btn_a">1</a>
								</button>
								<button class="btn border mx-2">
									<a href="#">2</a>
								</button>
								<button class="btn border mx-2">
									<a href="#">3</a>
								</button>
								<button class="btn border mx-2">
									<a href="#">4</a>
								</button>
								<button class="btn border mx-2">
									<a href="#">下一页</a>
								</button>
							</li>
							
						</ul>
					</div>
<!--					<div class="card-footer w-100" style="margin-top: 441px;">-->
<!--						<p style="color: #000000;">&copy;后台管理</p>-->
<!--					</div>-->
				</li>
				
			</ul>
			
		</div>
	</body>

	<script type="text/javascript">
		function se(){
			location.href="http://localhost:3031/?search="+$('#sar').val();
		};

		function del(id){
			$.ajax({
				url : '/del/'+id,
				success : function (res){
					if(res.status ==1){

						location.reload();
					}else{
						alert('删除失败')
					}
				}
			})
		}

	</script>
</html>

